package com.Liuhang.Dao;

import com.Liuhang.JDBC.util;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;

public class user_del extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            Statement st = util.getStatement();
            int id = Integer.valueOf(req.getParameter("id")).intValue();
            String sql = "DELETE FROM t_emp WHERE id = "+id+" ";
            st.execute(sql);
            ServletContext context = this.getServletContext();
            context.getRequestDispatcher("/Emplist.jsp").forward(req,resp);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
